package Lesson.Student.arrayListDemo;

import Domain.Student;

import java.util.ArrayList;
import java.util.Scanner;

public class Demo5 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();

        for(int i = 0; i < 3; i++){
            list.add(getStudent());
        }

        print(list);
    }

    public static Student getStudent(){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入姓名：");
        String name = sc.next();
        System.out.println("请输入年龄：");
        int age = sc.nextInt();
        Student stu = new Student(name,age);
        return stu;
    }

    public static void print(ArrayList<Student> list){
        for (int i = 0; i < list.size(); i++) {
            Student stu =  list.get(i);
            System.out.println(stu.getName()+"..."+stu.getAge());
        }
    }
}
